/**
 * Created by gru on 15-1-22.
 */
define(["app"], function (app, BaseService) {

    var deps = ["$http", "BaseService"];

    function userExResource($http, BaseService) {
        return initResource($http, BaseService.restfulUrl + "address/");
    }

    var reqHeader = {
        "Content-Type" : "application/x-www-form-urlencoded;charset=utf-8"
    };

    function initResource($http, preUrl) {
        return {
            
        	searchAddress: function (keyWord, pageNo, pageSize) {        		
            	return $http.get(preUrl + "searchAddress",{
                    params: {
                    	keyWord: keyWord,
                    	pageNo: pageNo,
                    	pageSize: pageSize
                    }
            	 });
            },
            
        	queryOrgUsers: function (orgId, pageNo, pageSize) {        		
            	return $http.get(preUrl + "queryOrgUsers",{
                    params: {
                    	orgId: orgId,
                    	pageNo: pageNo,
                    	pageSize: pageSize
                    }
            	 });
            },
            
            /**
             * 组织结构下用户搜索
             */
            queryUsers: function (orgId, searchKey, pageNo, pageSize) {        		
            	return $http.get(preUrl + "queryOrgUsersByName",{
                    params: {
                    	orgId: orgId,
                    	userName: searchKey,
                    	pageNo: pageNo,
                    	pageSize: pageSize
                    }
            	 });
            },
        } ;       
    }
    

    userExResource.$inject = deps;
    return app.lazy.service("AddressResource", userExResource);
});
